<template>
  <div class></div>
</template>
<script>
import axios from "@/utils/requestdp";

export default {
  name: "APIqueryDbreyuantable",
  components: {},
  data() {
    return {};
  },
  computed: {
    ishistory: function () {
      return this.$store.state.daping.ishistorytime;
    },
    timerangarr: function () {
      return this.$store.state.daping.timepick;
    },
  },
  watch: {},
  mounted() {
    this.watchEvent()
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (
        this.$store.state.daping.intervalArr["APIqueryDbreyuantable"] !=
        undefined
      ) {
        return;
      }

      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);
      this.$store.state.daping.intervalArr["APIqueryDbreyuantable"] = [
        { interval: interval },
      ];
    },
    loadData() {
      let queryJson = {
        queries: [
          {
            metric:
              "pid,name,m_006t as m_001t,m_007t as m_002t,m_006p as m_001p,m_007p as m_002p,m_009q as m_003q,m_009qc as m_003qc,m_012qc as m_006qc",
            schema: "monitor",
            table: "measuredpoint",
          },
          {
            metric:
              "pid,name,m_001t,m_002t,m_001p,m_002p,m_003q,m_003qc,m_006qc",
            schema: "monitor",
            table: "boiler",
          },
        ],
      };

      // if (this.ishistory == "历史") {
      //   queryJson = {
      //     queries: [
      //       {
      //         metric:
      //           "pid,name,m_006t as m_001t,m_007t as m_002t,m_006p as m_001p,m_007p as m_002p,m_009q as m_003q,m_009qc as m_003qc,m_012qc as m_006qc",
      //         schema: "monitor",
      //         table: "measuredpoint",
      //       },
      //       {
      //         metric:
      //           "pid,name,m_001t,m_002t,m_001p,m_002p,m_003q,m_003qc,m_006qc",
      //         schema: "monitor",
      //         table: "boiler",
      //       },
      //     ],
      //     type: "history",
      //     startTime: this.timerangarr[0].getTime(),
      //     endTime: this.timerangarr[1].getTime(),
      //   };
      // }

      axios.post("/open/queryDb", queryJson).then((res) => {
        if (true) {
          //如果有则获取200中的结果
          this.$store.state.daping.queryDbreyuan = res.data
        }
      });
    },
  },
};
</script>
<style lang='scss' scoped>
</style>